V2EX  ›  英汉词典

Type Casting

释义 Definition

类型转换/类型强制转换:在编程中把一个值从一种数据类型转换为另一种数据类型的操作。常见于把整数转为浮点数、把父类引用转为子类、或在不同数值类型之间转换。某些语言区分显式转换(cast)隐式转换(coercion)

例句 Examples

I had to do type casting to turn the integer into a float.
我不得不做类型转换,把整数变成浮点数。

Incorrect type casting can cause data loss or runtime errors, especially when converting large numbers or downcasting objects.
不正确的类型强制转换可能导致数据丢失或运行时错误,尤其是在转换大数值或对对象进行向下转型时。

发音 Pronunciation (IPA)

/taɪp ˈkæstɪŋ/

词源 Etymology

type 来自希腊语 typos(“印记、模型、类型”),后来在英语中发展出“类别/类型”的含义;cast 原意与“投掷、浇铸成型”相关。在编程语境里,cast 比喻“把值‘铸成’另一种类型的形状”,因此 type casting 就是“把数据按另一种类型来解释或转换”。

相关词 Related Words

文学/经典著作中的出现 Literary Works

  • The C Programming Language(Kernighan & Ritchie)——讨论 C 语言中显式强制类型转换(casts)与数值提升等规则。
  • Effective Java(Joshua Bloch)——涉及泛型、类型安全与(不当)类型转换可能带来的风险与最佳实践。
  • C# in Depth(Jon Skeet)——讲解 C# 的显式/隐式转换、装箱拆箱与运行时类型检查。
  • Programming Language Pragmatics(Michael L. Scott)——从语言设计角度讨论类型系统、转换与强制转换(casting/coercion)。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1442 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 16:16 · PVG 00:16 · LAX 08:16 · JFK 11:16
♥ Do have faith in what you're doing.